-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(plugin-flow-builder): add test for conditional country
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
packages/botonic-plugin-flow-builder/tests/conditional-country.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { INPUT } from '@botonic/core' | ||
import { describe, test } from '@jest/globals' | ||
|
||
import { FlowText } from '../src/index' | ||
import { ProcessEnvNodeEnvs } from '../src/types' | ||
import { basicFlow } from './helpers/flows/basic' | ||
import { | ||
createFlowBuilderPlugin, | ||
createRequest, | ||
getContentsAfterPreAndBotonicInit, | ||
} from './helpers/utils' | ||
|
||
describe('Check the contents returned by the plugin after conditional country node', () => { | ||
process.env.NODE_ENV = ProcessEnvNodeEnvs.PRODUCTION | ||
const flowBuilderPlugin = createFlowBuilderPlugin(basicFlow) | ||
|
||
test.each([ | ||
['ES', 'Message only for Spain'], | ||
['FR', 'Message only for France'], | ||
['GB', 'Message only for United Kingdom'], | ||
['DE', 'Message for other countries'], | ||
])( | ||
'The content of the country %s is displayed', | ||
async (countryISO: string, messageExpected: string) => { | ||
const request = createRequest({ | ||
input: { data: 'countryConditional', type: INPUT.TEXT }, | ||
plugins: { | ||
// @ts-ignore | ||
flowBuilderPlugin, | ||
}, | ||
extraData: { | ||
language: 'en', | ||
country: countryISO, | ||
}, | ||
}) | ||
|
||
const { contents } = await getContentsAfterPreAndBotonicInit( | ||
request, | ||
flowBuilderPlugin | ||
) | ||
|
||
expect((contents[0] as FlowText).text).toBe(messageExpected) | ||
} | ||
) | ||
}) |