| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- import Yaml from '~/services/serializer/denormalizer/yaml'
- import { DENORMALIZER_TYPE } from '~/types/enums'
- describe('support()', () => {
- it('should support model yaml type', () => {
- expect(Yaml.support(DENORMALIZER_TYPE.YAML)).toBeTruthy()
- })
- it('should not support hydra type', () => {
- expect(Yaml.support(DENORMALIZER_TYPE.HYDRA)).toBeFalsy()
- })
- })
- describe('denormalize()', () => {
- it('should throw an error if file doesnt exist', () => {
- const path = './tests/unit/fixture/files/not_exist_file.yaml'
- expect(() => Yaml.denormalize({ path })).toThrowError()
- })
- it('should parse a Yaml file and return a JSON Object', () => {
- const path = './tests/unit/fixture/files/test.yaml'
- expect(Yaml.denormalize({ path })).toStrictEqual({
- abilities: {
- accesses: {
- action: 'display',
- services: {
- access: [
- {
- function: 'hasAbility',
- parameters: [{
- action: 'read',
- subject: 'user'
- }]
- }
- ],
- organization: [
- {
- function: 'hasModule',
- parameters: [
- 'Users'
- ]
- }
- ]
- }
- },
- student_registration: {
- action: 'display',
- services: {
- access: [
- {
- function: 'hasAbility',
- parameters: [{
- action: 'read',
- subject: 'student-registration'
- }]
- }
- ],
- organization: [
- {
- function: 'hasModule',
- parameters: [
- 'UsersSchool'
- ]
- }
- ]
- }
- }
- }
- })
- })
- })
|