Skip to content

Commit

Permalink
Add origin option to ICE config
Browse files Browse the repository at this point in the history
  • Loading branch information
lookasc committed Nov 21, 2023
1 parent 56b6e04 commit 7116903
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/phrase-config.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ export type PhraseConfig = {
};
fullReparse: boolean;
sanitize?: (content: string)=> string;
origin: string;
};
1 change: 1 addition & 0 deletions src/vue-i18n-phrase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default class VueI18nPhrase {
suffix: '__}}',
useOldICE: false,
fullReparse: true,
origin: 'vue-i18n-phrase-in-context-editor'
};

private phraseScript?: HTMLScriptElement;
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/vue-i18n-phrase.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,24 @@ describe('constructor', () => {
initializeICE();
expect(phraseScript).not.toBeNull();
});

it('should add script tag with phrase url', () => {
initializeICE();
expect(phraseScript?.src.substring(0, 19)).toBe('https://phrase.com/');
});

it('should add script tag with new ice url', () => {
useOldICE = false;
initializeICE();

expect(phraseScript?.src.includes('d2bgdldl6xit7z.cloudfront')).toBe(true);
});

it('should set window.PHRASEAPP_ENABLED', () => {
initializeICE();
expect(window.PHRASEAPP_ENABLED).toBeTruthy();
});

describe('when script element already exists in the document', () => {
let script: HTMLScriptElement;
beforeEach(() => {
Expand All @@ -62,6 +66,11 @@ describe('constructor', () => {
expect(phraseScript?.nextElementSibling).toBe(script);
});
});

it('should set origin', () => {
initializeICE();
expect(window.PHRASEAPP_CONFIG.origin).toBe('vue-i18n-phrase-in-context-editor');
});
});

describe('when phraseEnabled = false', () => {
Expand Down

0 comments on commit 7116903

Please sign in to comment.