// 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', () => { assert.equal(makerworld.downloadProblem({ name: 'bookmarks.3mf', url: 'https://cdn.example/bookmarks.3mf' }), null); assert.match(makerworld.downloadProblem({ code: 1, error: 'Please log in to download models.' }), /token \(it has probably expired\)/); assert.equal(makerworld.downloadProblem({ code: 7, error: 'Model not found' }), 'MakerWorld didn’t give a download link: Model not found'); assert.equal(makerworld.downloadProblem(null), 'MakerWorld didn’t give a download link'); });