-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:storyblok/field-plugin
- Loading branch information
Showing
22 changed files
with
241 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ name: Publish CLI to NPM | |
|
||
on: | ||
release: | ||
types: [created] | ||
types: [published] | ||
|
||
jobs: | ||
publish-npm: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ name: Publish library to NPM | |
|
||
on: | ||
release: | ||
types: [created] | ||
types: [published] | ||
|
||
jobs: | ||
publish-npm: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
166 changes: 166 additions & 0 deletions
166
...d-plugin/src/messaging/pluginMessage/containerToPluginMessage/StateChangedMessage.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
import { isStateMessage, StateChangedMessage } from './StateChangedMessage' | ||
import { FieldPluginSchema } from './FieldPluginSchema' | ||
|
||
const stub: StateChangedMessage = { | ||
action: 'state-changed', | ||
uid: '-preview', | ||
spaceId: null, | ||
userId: undefined, | ||
model: undefined, | ||
isModalOpen: false, | ||
token: null, | ||
storyId: undefined, | ||
blockId: undefined, | ||
story: { content: {} }, | ||
language: '', | ||
interfaceLanguage: 'en', | ||
schema: { options: [], field_type: 'blah', translatable: false }, | ||
releases: [], | ||
releaseId: undefined, | ||
} | ||
|
||
describe('StateChangedMessage', () => { | ||
it('should validate', () => { | ||
expect(isStateMessage(stub)).toEqual(true) | ||
}) | ||
describe('The "action" property', () => { | ||
it('equals "loaded"', () => { | ||
expect( | ||
isStateMessage({ | ||
...stub, | ||
action: 'anotherString', | ||
}), | ||
).toEqual(false) | ||
}) | ||
}) | ||
describe('the "uid" property', () => { | ||
it('is a string', () => { | ||
expect( | ||
isStateMessage({ | ||
...stub, | ||
uid: 'anything', | ||
}), | ||
).toEqual(true) | ||
}) | ||
it('is not undefined', () => { | ||
expect( | ||
isStateMessage({ | ||
...stub, | ||
uid: undefined, | ||
}), | ||
).toEqual(false) | ||
}) | ||
it('is not null', () => { | ||
expect( | ||
isStateMessage({ | ||
...stub, | ||
uid: null, | ||
}), | ||
).toEqual(false) | ||
}) | ||
it('is not a number', () => { | ||
expect( | ||
isStateMessage({ | ||
...stub, | ||
uid: 123, | ||
}), | ||
).toEqual(false) | ||
}) | ||
}) | ||
|
||
describe('the "language" property', () => { | ||
it('is a string', () => { | ||
expect( | ||
isStateMessage({ | ||
...stub, | ||
language: 'anything', | ||
}), | ||
).toEqual(true) | ||
}) | ||
it('is not undefined', () => { | ||
expect( | ||
isStateMessage({ | ||
...stub, | ||
language: undefined, | ||
}), | ||
).toEqual(false) | ||
}) | ||
it('is not null', () => { | ||
expect( | ||
isStateMessage({ | ||
...stub, | ||
language: null, | ||
}), | ||
).toEqual(false) | ||
}) | ||
it('is not a number', () => { | ||
expect( | ||
isStateMessage({ | ||
...stub, | ||
language: 123, | ||
}), | ||
).toEqual(false) | ||
}) | ||
}) | ||
describe('The "schema" property', () => { | ||
it('is required', () => { | ||
expect( | ||
isStateMessage({ | ||
...stub, | ||
schema: undefined, | ||
}), | ||
).toEqual(false) | ||
}) | ||
it('must be a schema', () => { | ||
expect( | ||
isStateMessage({ | ||
...stub, | ||
schema: { | ||
field_type: 'my-field', | ||
options: [ | ||
{ | ||
name: 'a', | ||
value: 'ab', | ||
}, | ||
], | ||
translatable: false, | ||
} as FieldPluginSchema, | ||
}), | ||
).toEqual(true) | ||
}) | ||
}) | ||
describe('The "userId" property', () => { | ||
it('is a number', () => { | ||
expect( | ||
isStateMessage({ | ||
...stub, | ||
userId: 123, | ||
}), | ||
).toEqual(true) | ||
}) | ||
it('is undefined', () => { | ||
expect( | ||
isStateMessage({ | ||
...stub, | ||
userId: undefined, | ||
}), | ||
).toEqual(true) | ||
}) | ||
it('is not null', () => { | ||
expect( | ||
isStateMessage({ | ||
...stub, | ||
userId: null, | ||
}), | ||
).toEqual(false) | ||
}) | ||
it('is not a string', () => { | ||
expect( | ||
isStateMessage({ | ||
...stub, | ||
userId: '123', | ||
}), | ||
).toEqual(false) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.