Created
December 4, 2015 15:21
-
-
Save ultimatemonty/ee854397eb9f7370f397 to your computer and use it in GitHub Desktop.
adpater test
This file contains hidden or 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
import { moduleFor, test } from 'ember-qunit'; | |
moduleFor('adapter:email-template-link', 'Unit | Adapter | email template link', { | |
// Specify the other units that are required for this test. | |
// needs: ['serializer:foo'] | |
beforeEach: function() { | |
const payload = { | |
"email_templates": [{ | |
"id": "6", | |
"name": "Drip Marketing - Scoring and Nurturing Whitepaper", | |
"urls": [{ | |
"url": "http://www2.pardot.com/l/1/2009-03-05/C3X0G/10054_Automate_Nurturing_and_Scoring.pdf", | |
"template_type": "html" | |
}, { | |
"url": "http://pardot.com/files/flash/", | |
"template_type": "html" | |
}, { | |
"url": "http://www2.pardot.com/l/1/2009-03-05/C3X0G/10054_Automate_Nurturing_and_Scoring.pdf", | |
"template_type": "text" | |
}, { | |
"url": "http://pardot.com/files/flash/", | |
"template_type": "text" | |
}] | |
}] | |
}; | |
this.payload = payload; | |
} | |
}); | |
// Replace this with your real tests. | |
test('it exists', function(assert) { | |
let adapter = this.subject(); | |
let payload = this.payload; | |
adapter.set('isSuccess', true); // assume success | |
let formattedPayload = adapter.handleResponse(null, null, payload); | |
let expectedPayload = { | |
"emailTemplateLinks": [{ | |
"emailTemplateId": "6", | |
"id": "ember275", | |
"templateType": "html", | |
"url": "http://www2.pardot.com/l/1/2009-03-05/C3X0G/10054_Automate_Nurturing_and_Scoring.pdf" | |
}, { | |
"emailTemplateId": "6", | |
"id": "ember276", | |
"templateType": "html", | |
"url": "http://pardot.com/files/flash/" | |
}, { | |
"emailTemplateId": "6", | |
"id": "ember277", | |
"templateType": "text", | |
"url": "http://www2.pardot.com/l/1/2009-03-05/C3X0G/10054_Automate_Nurturing_and_Scoring.pdf" | |
}, { | |
"emailTemplateId": "6", | |
"id": "ember278", | |
"templateType": "text", | |
"url": "http://pardot.com/files/flash/" | |
}] | |
}; | |
assert.deepEqual(formattedPayload, expectedPayload); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment