Guest User

Untitled

a guest
May 25th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #!/usr/bin/env node
  2. 'use strict';
  3.  
  4. const assert = require('assert');
  5. const mongoose = require('mongoose');
  6. mongoose.connect('mongodb://localhost/test');
  7. const conn = mongoose.connection;
  8. const Schema = mongoose.Schema;
  9.  
  10. const schema = new Schema({
  11. reply_markup: {
  12. inline_keyboard: [
  13. [Schema.Types.Mixed],
  14. [Schema.Types.Mixed]
  15. ]
  16. }
  17. });
  18.  
  19. const Test = mongoose.model('test', schema);
  20.  
  21. const test = new Test({
  22. reply_markup: {
  23. inline_keyboard: [
  24. [{ text: 'one', callback_data: 'data' }],
  25. [{ text: 'two', url: 'url'}]
  26. ]
  27. }
  28. });
  29.  
  30. async function run() {
  31. await conn.dropDatabase();
  32. await test.save();
  33. let { reply_markup } = await Test.findOne({}).lean();
  34. assert.strictEqual(reply_markup.inline_keyboard[0][0].text, 'one');
  35. assert.strictEqual(reply_markup.inline_keyboard[0][0].callback_data, 'data');
  36. assert.strictEqual(reply_markup.inline_keyboard[1][0].text, 'two');
  37. assert.strictEqual(reply_markup.inline_keyboard[1][0].url, 'url');
  38. return conn.close();
  39. }
  40.  
  41. run();
Add Comment
Please, Sign In to add comment