Skip to content

Commit

Permalink
SK-1395 : Test Cases update
Browse files Browse the repository at this point in the history
  • Loading branch information
skyflow-shashank-prajapati committed Jan 22, 2024
1 parent c9dcbdd commit e0d95ad
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/core/internal/iframe-form/iframe-form.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,59 @@ describe('test iframeForm collect method', () => {
}
}));
})
test('inputElementNotFound', (done) => {
const form = new IFrameForm("controllerId", "", "ERROR");
const element = new IFrameFormElement(collect_element,"",{},context)
form.setClient(clientObj1)
form.setClientMetadata(metaData)
form.setContext(context)

element.setValue("123")
const skyflowInit = jest.fn();
let windowSpy = jest.spyOn(global, 'window', 'get');
windowSpy.mockImplementation(() => ({
parent: {
frames: {
[`${collect_element}:controllerId:ERROR`]:{
document:{
getElementById:()=>(undefined)
}
}
}
},
location: {
href: 'http://iframe.html'
}
}));

const tokenizationEvent = on.mock.calls.filter((data) => data[0] === ELEMENT_EVENTS_TO_IFRAME.TOKENIZATION_REQUEST + 'controllerId');
const tokenizationCb = tokenizationEvent[0][1];
const cb2 = jest.fn();
tokenizationCb({...data,elementIds:[{elementId:collect_element,frameId:collect_element}]}, cb2);
setTimeout(() => {
expect(cb2.mock.calls[0][0].error).toBeDefined();
done()
}, 1000)
form.tokenize({...data,elementIds:[{elementId:collect_element,frameId:collect_element}]}).then().catch( err => {
expect(err).toBeDefined();
})
windowSpy.mockImplementation(() => ({
parent: {
frames: [{
name: collect_element,
location: {
href: 'http://iframe.html'
},
Skyflow: {
init: skyflowInit
}
}]
},
location: {
href: 'http://iframe.html'
}
}));
})
test('success', (done) => {
const form = new IFrameForm("controllerId", "", "ERROR");
const element = new IFrameFormElement(collect_element,"",{},context)
Expand Down

0 comments on commit e0d95ad

Please sign in to comment.