From d7f49f973b5ac7ccbf043e73c7ac4f2eba1539fe Mon Sep 17 00:00:00 2001 From: Doug Parker Date: Sat, 30 Apr 2022 16:19:24 -0700 Subject: [PATCH] Updates resource injector to inject inline styles. Refs #41. The resource injector now processes the input HTML to look for any inline style annotations replaces them with a ` + + + `.trim()); + }); + + it('throws on any annotations other than inline style annotations', async () => { + // Should fail when given a script annotation. + const scriptAnnotation = createAnnotation({ + type: 'script', + path: 'foo.js', + }); + const inputWithScriptAnnotation = ` + + + + Some title + + +

Hello, World!

+ + + + `.trim(); + await expectAsync(inject(inputWithScriptAnnotation, [])) + .toBeRejectedWithError( + /Injector found an annotation which is not an inline style/); + + // Should fail when given a global style annotation. + const globalStyleAnnotation = createAnnotation({ + type: 'style', + path: 'foo.css', + scope: StyleScope.Global, + }); + const inputWithGlobalStyleAnnotation = ` + + + + Some title + + +

Hello, World!

+ + + + `.trim(); + await expectAsync(inject(inputWithGlobalStyleAnnotation, [])) + .toBeRejectedWithError( + /Injector found an annotation which is not an inline style/); + }); }); });