test('preParsing hooks can completely ignore the payload - deprecated syntax', t => { t.plan(5) const fastify = Fastify() process.on('warning', onWarning) warning.emitted.delete('FSTDEP004') function onWarning (warning) { t.strictEqual(warning.name, 'FastifyDeprecation') t.strictEqual(warning.code, 'FSTDEP004') } fastify.addHook('preParsing', (req, reply, done) => { done() }) fastify.post('/', function (request, reply) { reply.send(request.body) }) fastify.inject({ method: 'POST', url: '/', payload: { hello: 'world' } }, (err, res) => { t.error(err) t.equal(res.statusCode, 200) t.deepEqual(JSON.parse(res.payload), { hello: 'world' }) }) })
let ok = true; readers.forEach(reader => { if (reader.emitted.length !== 100) ok = false; });
it('emet un événement réponse quand on appuie sur le bouton envoi', function () { question.choix = [{ id: 'uid-32', bonneReponse: true }]; const vue = shallowMount(VueQCM, { localVue, propsData: { question } }); vue.find('input[type=radio][value=uid-32]').setChecked(); vue.find('.question-bouton').trigger('click'); expect(vue.emitted('reponse').length).to.eql(1); expect(vue.emitted('reponse')[0][0]).to.eql({ reponse: 'uid-32', succes: true }); });
it("rend la question d'identification du danger puis informe du résultat puis de qualification puis c'est terminé", function () { expect(wrapper.vm.etat).to.equal('identification'); wrapper.vm.question.submit(); expect(wrapper.vm.etat).to.equal('resultat-identification'); wrapper.vm.termineIdentification(); expect(wrapper.vm.etat).to.equal('qualification'); wrapper.vm.question.submit(); expect(wrapper.emitted('ferme').length).to.equal(1); });
it("une fois toutes les zones évaluées, envoie l'événement terminer", function () { wrapper.vm.survoleZone(zone1); wrapper.vm.selectionPrevention(); expect(wrapper.emitted('terminer')).to.be(undefined); wrapper.vm.survoleZone(zone2); wrapper.vm.selectionPrevention(); expect(wrapper.emitted('terminer').length).to.be(1); });
it('émet un événement terminer lorsque tout les dangers ont été identifiés', function () { store.commit('configureActe', { zones: [{ x: 1, y: 2, r: 3, danger: 'danger1' }, { x: 4, y: 5, r: 6, danger: 'danger2' }], dangers: { danger1: {}, danger2: {} } }); store.commit('ajouteDangerQualifie', { nom: 'danger1', choix: 'bon' }); expect(wrapper.emitted('terminer')).to.be(undefined); store.commit('ajouteDangerQualifie', { nom: 'danger2', choix: 'mauvais' }); expect(wrapper.emitted('terminer').length).to.eql(1); });
describe('has not been closed', () => { let confirmButton beforeEach(() => { propsData = { ...propsData, report: reports[1] } wrapper = Wrapper() confirmButton = wrapper.find('.base-button.--danger') }) it('renders a confirm button', () => { expect(confirmButton.exists()).toBe(true) }) it('emits confirm event', () => { confirmButton.trigger('click') expect(wrapper.emitted('confirm-report')).toHaveLength(1) }) })
it("terminer est à true lorsque l'on a vu tout les mots", function () { let appelAMotSuivant = 0; wrapper.setMethods({ motSuivantAvecDelai () { appelAMotSuivant++; } }); expect(wrapper.vm.termine).to.be(false); wrapper.vm.afficheMot(); wrapper.vm.afficheMot(); expect(wrapper.emitted('terminer')).to.be(undefined); wrapper.vm.afficheMot(); expect(wrapper.vm.termine).to.be(true); expect(wrapper.emitted('terminer')).to.be(undefined); wrapper.vm.motSuivant(); expect(wrapper.emitted('terminer').length).to.eql(1); expect(appelAMotSuivant).to.eql(0); });
describe('unread status', () => { it('does not have class `notification-status`', () => { expect(wrapper.find('.notification-status').exists()).toBe(false) }) it('clicking on a Post link emits `markNotificationAsRead`', () => { wrapper.find('a.notification-mention-post').trigger('click') expect(wrapper.emitted().markNotificationAsRead[0][0]).toEqual(postNotification.from.id) }) it('adds class `notification-status` when read is true', () => { postNotification.read = true wrapper = Wrapper() expect(wrapper.find('.notification-status').exists()).toBe(true) }) })
it('émet un évement réponse pour une question numérique', function () { question.numerique = true; question.bonneReponse = '1800'; const vue = shallowMount(VueQCM, { localVue, propsData: { question } }); vue.vm.reponse = '1800'; vue.vm.envoi(); expect(vue.emitted('reponse').length).to.eql(1); expect(vue.emitted('reponse')[0][0]).to.eql({ reponse: '1800', succes: true }); });
describe('test update comment', () => { beforeEach(() => { wrapper = Wrapper() }) describe('with a given comment', () => { beforeEach(async () => { await wrapper.vm.updateComment({ id: 'it-is-the-updated-comment', }) }) it('emits "updateComment"', () => { expect(wrapper.emitted('updateComment')).toEqual([ [ { id: 'it-is-the-updated-comment', }, ], ]) }) }) })
describe('click reply button', () => { beforeEach(async () => { wrapper = Wrapper() await wrapper.find('.reply-button').trigger('click') }) it('emits "reply"', () => { expect(wrapper.emitted('reply')).toEqual([ [ { id: 'commentAuthorId', slug: 'ogerly', }, ], ]) }) })
describe("La fenêtre d'aide", function () { let wrapper; beforeEach(function () { wrapper = shallowMount(FenetreAide, { propsData: { contexte: '' } }); }); it('au click sur le bouton, envoi un événement', function () { wrapper.find('button').trigger('click'); expect(wrapper.emitted(FERME).length).to.eql(1); }); });
describe('test callbacks', () => { beforeEach(() => { wrapper = Wrapper() }) describe('deletion of Comment from List by invoking "deleteCommentCallback()"', () => { beforeEach(async () => { await wrapper.vm.deleteCommentCallback() }) it('emits "deleteComment"', () => { expect(wrapper.emitted('deleteComment')).toEqual([ [ { id: 'it-is-the-deleted-comment', }, ], ]) }) it('does call mutation', () => { expect(mocks.$apollo.mutate).toHaveBeenCalledTimes(1) }) it('mutation is successful', () => { expect(mocks.$toast.success).toHaveBeenCalledTimes(1) }) }) })