2023-01-17 17:06:00 +01:00
|
|
|
import {
|
|
|
|
ConfirmModal,
|
2023-01-18 03:40:02 +01:00
|
|
|
ImagesLightbox,
|
2023-01-17 17:06:00 +01:00
|
|
|
ShellUiModel,
|
|
|
|
} from './../../../src/state/models/shell-ui'
|
|
|
|
|
|
|
|
describe('ShellUiModel', () => {
|
|
|
|
let model: ShellUiModel
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
model = new ShellUiModel()
|
|
|
|
})
|
|
|
|
|
|
|
|
afterAll(() => {
|
|
|
|
jest.clearAllMocks()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should call the openModal & closeModal method', () => {
|
2023-01-18 03:40:02 +01:00
|
|
|
const m = new ConfirmModal('Test Modal', 'Look good?', () => {})
|
|
|
|
model.openModal(m)
|
2023-01-17 17:06:00 +01:00
|
|
|
expect(model.isModalActive).toEqual(true)
|
2023-01-18 03:40:02 +01:00
|
|
|
expect(model.activeModal).toEqual(m)
|
2023-01-17 17:06:00 +01:00
|
|
|
|
|
|
|
model.closeModal()
|
|
|
|
expect(model.isModalActive).toEqual(false)
|
|
|
|
expect(model.activeModal).toBeUndefined()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should call the openLightbox & closeLightbox method', () => {
|
2023-01-18 03:40:02 +01:00
|
|
|
const lt = new ImagesLightbox(['uri'], 0)
|
|
|
|
model.openLightbox(lt)
|
2023-01-17 17:06:00 +01:00
|
|
|
expect(model.isLightboxActive).toEqual(true)
|
2023-01-18 03:40:02 +01:00
|
|
|
expect(model.activeLightbox).toEqual(lt)
|
2023-01-17 17:06:00 +01:00
|
|
|
|
|
|
|
model.closeLightbox()
|
|
|
|
expect(model.isLightboxActive).toEqual(false)
|
|
|
|
expect(model.activeLightbox).toBeUndefined()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should call the openComposer & closeComposer method', () => {
|
|
|
|
const composer = {
|
|
|
|
replyTo: {
|
|
|
|
uri: 'uri',
|
|
|
|
cid: 'cid',
|
|
|
|
text: 'text',
|
|
|
|
author: {
|
|
|
|
handle: 'handle',
|
|
|
|
displayName: 'name',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onPost: jest.fn(),
|
|
|
|
}
|
|
|
|
model.openComposer(composer)
|
|
|
|
expect(model.isComposerActive).toEqual(true)
|
|
|
|
expect(model.composerOpts).toEqual(composer)
|
|
|
|
|
|
|
|
model.closeComposer()
|
|
|
|
expect(model.isComposerActive).toEqual(false)
|
|
|
|
expect(model.composerOpts).toBeUndefined()
|
|
|
|
})
|
|
|
|
})
|