+ Refus +
++ Creation contrat +
++ Pas de creation +
+ ++ Section contrats masquee, aucune directive appliquee. +
++ Suppression interdite +
++ {{ String(canProxy.employee.view) }} +
+Refus
+ `) + + expect(code).toContain(`v-if="__can__(['employee', 'view'])"`) + expect(code).toContain(`v-if="!(__can__(['employee', 'view']))"`) + }) + + it('merges existing v-if expressions with the generated guard', () => { + const code = runTransform(` + + `) + + expect(code).toContain(`v-if="(isReady) && __can__(['contract', 'create'])"`) + }) + + it('throws when v-cannot is used without a preceding v-can', () => { + const exec = () => transformCan({ + code: buildSFC('Denied
'), + id: TEST_FILE, + }) + + expect(exec).toThrow(/must immediately follow its `v-can`/) + }) + + it('throws when the expression does not start with can.*', () => { + const exec = () => transformCan({ + code: buildSFC(''), + id: TEST_FILE, + }) + + expect(exec).toThrow(/expressions must start with `can\.`/) + }) + + it('throws when v-can is added to a v-else branch', () => { + const exec = () => transformCan({ + code: buildSFC(` + + + `), + id: TEST_FILE, + }) + + expect(exec).toThrow(/cannot be used on `v-else`/) + }) +})