Skip to content

Commit

Permalink
test(plugin-flow-builder): add test for conditional country
Browse files Browse the repository at this point in the history
  • Loading branch information
Iru89 committed May 14, 2024
1 parent 110cddd commit fa6d82d
Showing 1 changed file with 45 additions and 0 deletions.
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)
}
)
})

0 comments on commit fa6d82d

Please sign in to comment.