// MakerWorld importer helpers (lib/importers/makerworld.js). const test = require('node:test'); const assert = require('node:assert/strict'); const makerworld = require('../lib/importers/makerworld'); const page = (design) => ``; test('printable instances and the license are read from the page data', () => { const html = page({ license: 'Standard Digital File License', instances: [{ id: 650088, title: 'AMS - 0.4 Nozzle - 0.08 Layer' }, { id: 650089 }], }); assert.deepEqual(makerworld.parseInstances(html), [ { id: 650088, title: 'AMS - 0.4 Nozzle - 0.08 Layer' }, { id: 650089, title: '' }, ]); assert.equal(makerworld.parseLicense(html), 'Standard Digital File License'); assert.deepEqual(makerworld.parseInstances('Just a moment...'), []); }); test('a download answer without a link says why, and flags a refused token', () => { assert.equal(makerworld.downloadProblem({ name: 'bookmarks.3mf', url: 'https://cdn.example/bookmarks.3mf' }), null); const refused = makerworld.downloadProblem({ code: 1, error: 'Please log in to download models.' }); assert.equal(refused.tokenRejected, true); assert.match(refused.message, /token \(it has probably expired\)/); assert.deepEqual(makerworld.downloadProblem({ code: 7, error: 'Model not found' }), { message: 'MakerWorld didn’t give a download link: Model not found', tokenRejected: false }); assert.deepEqual(makerworld.downloadProblem(null), { message: 'MakerWorld didn’t give a download link', tokenRejected: false }); });